package service.Imp;

import Dao.RoomMasterDao;
import Dao.UserFollowDao;
import Dao.UserVideoDao;
import modal.RoomMaster;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import service.ActivityService;

import java.util.List;

/**
 * Created by tan on 2017/8/24.
 * 14:12
 */
@Service
public class ActivityServiceImp implements ActivityService {

    @Autowired
    RoomMasterDao roomMasterDao;
    @Autowired
    UserFollowDao userFollowDao;
    @Autowired
    UserVideoDao userVideoDao;


    public String followEvent(String username, String roomid) {
        if (userFollowDao.addMyFollow(username,roomid))
        {
            RoomMaster user=roomMasterDao.getRoomMasterByRoomid(roomid);
            user.setPoint(user.getPoint()+10);
            return roomMasterDao.updateRoomMaster(user);

        }
        return "error";
    }

    public String unfollowEvent(String username, String roomid) {
        if(userFollowDao.deleteMyFollow(username,roomid))return "success";
        else return "error";
    }

    public List getListLive() {
       return roomMasterDao.getAllRoom();
    }

    public List getListVideo(String name) {
        return userVideoDao.getVideoByName(name);
    }

    public String hasFollow(String username, String roomid) {
        return userFollowDao.hasFollow(username,roomid);
    }
}
